<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include_once("conn.php");
$id=$_REQUEST['id'];
$sql = "SELECT * FROM shouke WHERE `tid` = '$id'";
$result=mysql_query($sql);
while($row = mysql_fetch_row($result)){
	$cid[]=$row[2];
}
$sid=array_unique(getStudentId($cid));

$students=getStudentInfo($sid);
foreach($students as $stu){
?>
	<table border="1" bordercolor="#ffffff" style="BORDER-COLLAPSE: collapse; color: #FFF"; width="50%" bgcolor="#6589d1" class="h">
  <tr style="text-align: center">
    <td width="21%">学号</td>
    <td width="79%"><?=$stu[0]?></td>
  </tr>
  <tr style="text-align: center">
    <td>姓名</td>
    <td><?=$stu[1]?></td>
  </tr>
  <tr style="text-align: center">
    <td>性别</td>
    <td><?=$stu[3]==0?"男":"女"?></td>
  </tr>
  <tr style="text-align: center">
    <td>学院</td>
    <td><?=$stu[4]?></td>
  </tr>
  <tr style="text-align: center">
    <td>专业</td>
    <td><?=$stu[5]?></td>
  </tr>
  <tr style="text-align: center">
    <td>出生年月</td>
    <td><?=$stu[6].".".$stu[7]?></td>
  </tr>
  <tr style="text-align: center">
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  </table>
<?php
}

mysql_close($conn);

function getStudentId($cid){
	$sql = "SELECT * FROM xuanke WHERE";
	foreach ($cid as $value){
		$sql.=" `cid` =$value OR";
	}
	$sql = substr($sql,0,strlen($sql)-3);
	$result=mysql_query($sql);
	while($row = mysql_fetch_row($result)){
		$sid[]=$row[1];
	}
	return $sid;
}

function getStudentInfo($sid){
	$sql = "SELECT * FROM student WHERE";
	foreach ($sid as $value){
		$sql.=" `id` =$value OR";
	}
	$sql = substr($sql,0,strlen($sql)-3);
	$result=mysql_query($sql);
	while($row = mysql_fetch_row($result)){
		$stu[]=$row;
	}
	return $stu;
}
?>
</body>
</html>